package org.example.entity;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class AjaxResult {

    private int code;
    private String message;
    private Object data;

    /**
     * 成功
     * @return
     */
    public static AjaxResult ok(){
        return new AjaxResult(200,"success",null);
    }

    public static AjaxResult ok(Object data){
        return new AjaxResult(200,"success",data);
    }

    /**
     * 错误
     * @param code
     * @param message
     * @return
     */
    public static AjaxResult err(int code,String message){
        return new AjaxResult(code,message,null);
    }

    public static AjaxResult err(){
        return new AjaxResult(500,"error",null);
    }
    public static AjaxResult err(String message){
        return new AjaxResult(500,message,null);
    }
}
